home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / xshogi11.lha / xshogi-1.1 / parser.c < prev    next >
C/C++ Source or Header  |  1993-04-13  |  23KB  |  897 lines

  1.  
  2. /*  A Bison parser, made from parser.bison  */
  3.  
  4. #define    PROMOTE    258
  5. #define    DROPS    259
  6. #define    PIECE    260
  7. #define    SQUARE    261
  8. #define    NUMBER    262
  9. #define    CROSS    263
  10. #define    COLON    264
  11.  
  12. #line 2 "parser.bison"
  13.  
  14.  
  15. /*
  16.  * parser.c - C source for Xshogi
  17.  *
  18.  * Copyright (c) 1993 Matthias Mutz
  19.  *
  20.  * XShogi is based on XBoard 2.0
  21.  *
  22.  * Copyright (c) 1992 Free Software Foundation
  23.  *
  24.  * This file is part of XShogi.
  25.  *
  26.  * XShogi is free software; you can redistribute it and/or modify
  27.  * it under the terms of the GNU General Public License as published by
  28.  * the Free Software Foundation; either version 1, or (at your option)
  29.  * any later version.
  30.  *
  31.  * XShogi is distributed in the hope that it will be useful,
  32.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  33.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  34.  * GNU General Public License for more details.
  35.  *
  36.  * You should have received a copy of the GNU General Public License
  37.  * along with XShogi; see the file COPYING.  If not, write to
  38.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  39.  */
  40.  
  41. #include "xshogi.h"
  42. #include <stdio.h>
  43. #include <stdlib.h>
  44. #include <string.h>
  45.                   
  46. enum { False, True };
  47.  
  48. static void yyerror();
  49.            
  50. static ChessMove move_type;
  51. static int      from_x, from_y, to_x, to_y;
  52. static char      piece;
  53.  
  54. char currentMoveString[MSG_SIZ];
  55.  
  56. FILE *outfile = (FILE *)0;
  57.  
  58. extern FILE     *gameFileFP, *toFirstProgFP;
  59. extern int     currentMove;
  60. extern char      moveList[MAX_MOVES][MOVE_LEN];
  61.  
  62. extern void SendToProgram P((char *message, FILE *fp));
  63. extern void MakeMove P((ChessMove *move_type, int from_x, int from_y, int to_x, int to_y));
  64.  
  65.  
  66. #line 60 "parser.bison"
  67. typedef union { int val; char* string; } YYSTYPE;
  68.  
  69. #ifndef YYLTYPE
  70. typedef
  71.   struct yyltype
  72.     {
  73.       int timestamp;
  74.       int first_line;
  75.       int first_column;
  76.       int last_line;
  77.       int last_column;
  78.       char *text;
  79.    }
  80.   yyltype;
  81.  
  82. #define YYLTYPE yyltype
  83. #endif
  84.  
  85. #include <stdio.h>
  86.  
  87. #ifndef __STDC__
  88. #define const
  89. #endif
  90.  
  91.  
  92.  
  93. #define    YYFINAL        24
  94. #define    YYFLAG        -32768
  95. #define    YYNTBASE    10
  96.  
  97. #define YYTRANSLATE(x) ((unsigned)(x) <= 264 ? yytranslate[x] : 22)
  98.  
  99. static const char yytranslate[] = {     0,
  100.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  101.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  102.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  103.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  104.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  105.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  106.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  107.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  108.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  109.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  110.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  111.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  112.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  113.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  114.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  115.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  116.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  117.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  118.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  119.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  120.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  121.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  122.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  123.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  124.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  125.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  126.      6,     7,     8,     9
  127. };
  128.  
  129. static const short yyprhs[] = {     0,
  130.      0,     3,     4,     9,    10,    13,    14,    16,    17,    18,
  131.     19,    26,    27,    28,    29,    36,    37
  132. };
  133.  
  134. static const short yyrhs[] = {     8,
  135.     11,     0,     0,    11,    12,    13,    14,     0,     0,     7,
  136.      9,     0,     0,     3,     0,     0,     0,     0,     6,    15,
  137.      6,    16,    17,    21,     0,     0,     0,     0,     5,    18,
  138.      4,    19,     6,    20,     0,     0,     3,     0
  139. };
  140.  
  141. #if YYDEBUG != 0
  142. static const short yyrline[] = { 0,
  143.     64,    68,    69,    72,    73,    76,    77,    80,    84,    87,
  144.     89,    94,    96,    97,   100,   121,   122
  145. };
  146.  
  147. static const char * const yytname[] = {   "$",
  148. "error","$illegal.","PROMOTE","DROPS","PIECE","SQUARE","NUMBER","CROSS","COLON","goal",
  149. "move_list","number","promoted","move","@1","@2","@3","@4","@5","@6",
  150. "promotion",""
  151. };
  152. #endif
  153.  
  154. static const short yyr1[] = {     0,
  155.     10,    11,    11,    12,    12,    13,    13,    15,    16,    17,
  156.     14,    18,    19,    20,    14,    21,    21
  157. };
  158.  
  159. static const short yyr2[] = {     0,
  160.      2,     0,     4,     0,     2,     0,     1,     0,     0,     0,
  161.      6,     0,     0,     0,     6,     0,     1
  162. };
  163.  
  164. static const short yydefact[] = {     0,
  165.      2,     4,     0,     6,     5,     7,     0,    12,     8,     3,
  166.      0,     0,    13,     9,     0,    10,    14,    16,    15,    17,
  167.     11,     0,     0,     0
  168. };
  169.  
  170. static const short yydefgoto[] = {    22,
  171.      2,     4,     7,    10,    12,    16,    18,    11,    15,    19,
  172.     21
  173. };
  174.  
  175. static const short yypact[] = {    -5,
  176. -32768,     0,    -3,     1,-32768,-32768,    -4,-32768,-32768,-32768,
  177.      4,    -1,-32768,-32768,     3,-32768,-32768,     7,-32768,-32768,
  178. -32768,    11,    12,-32768
  179. };
  180.  
  181. static const short yypgoto[] = {-32768,
  182. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  183. -32768
  184. };
  185.  
  186.  
  187. #define    YYLAST        12
  188.  
  189.  
  190. static const short yytable[] = {    -1,
  191.      8,     9,     1,     6,    14,     5,     3,    13,    17,    20,
  192.     23,    24
  193. };
  194.  
  195. static const short yycheck[] = {     0,
  196.      5,     6,     8,     3,     6,     9,     7,     4,     6,     3,
  197.      0,     0
  198. };
  199. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  200. #line 3 "bison.simple"
  201.  
  202. /* Skeleton output parser for bison,
  203.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  204.  
  205.    This program is free software; you can redistribute it and/or modify
  206.    it under the terms of the GNU General Public License as published by
  207.    the Free Software Foundation; either version 1, or (at your option)
  208.    any later version.
  209.  
  210.    This program is distributed in the hope that it will be useful,
  211.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  212.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  213.    GNU General Public License for more details.
  214.  
  215.    You should have received a copy of the GNU General Public License
  216.    along with this program; if not, write to the Free Software
  217.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  218.  
  219.  
  220. #ifndef alloca
  221. #ifdef __GNUC__
  222. #define alloca __builtin_alloca
  223. #else /* Not GNU C.  */
  224. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
  225. #include <alloca.h>
  226. #else /* Not sparc */
  227. #ifdef MSDOS
  228. #include <malloc.h>
  229. #endif /* MSDOS */
  230. #endif /* Not sparc.  */
  231. #endif /* Not GNU C.  */
  232. #endif /* alloca not defined.  */
  233.  
  234. /* This is the parser code that is written into each bison parser
  235.   when the %semantic_parser declaration is not specified in the grammar.
  236.   It was written by Richard Stallman by simplifying the hairy parser
  237.   used when %semantic_parser is specified.  */
  238.  
  239. /* Note: there must be only one dollar sign in this file.
  240.    It is replaced by the list of actions, each action
  241.    as one case of the switch.  */
  242.  
  243. #define yyerrok        (yyerrstatus = 0)
  244. #define yyclearin    (yychar = YYEMPTY)
  245. #define YYEMPTY        -2
  246. #define YYEOF        0
  247. #define YYACCEPT    return(0)
  248. #define YYABORT     return(1)
  249. #define YYERROR        goto yyerrlab1
  250. /* Like YYERROR except do call yyerror.
  251.    This remains here temporarily to ease the
  252.    transition to the new meaning of YYERROR, for GCC.
  253.    Once GCC version 2 has supplanted version 1, this can go.  */
  254. #define YYFAIL        goto yyerrlab
  255. #define YYRECOVERING()  (!!yyerrstatus)
  256. #define YYBACKUP(token, value) \
  257. do                                \
  258.   if (yychar == YYEMPTY && yylen == 1)                \
  259.     { yychar = (token), yylval = (value);            \
  260.       yychar1 = YYTRANSLATE (yychar);                \
  261.       YYPOPSTACK;                        \
  262.       goto yybackup;                        \
  263.     }                                \
  264.   else                                \
  265.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  266. while (0)
  267.  
  268. #define YYTERROR    1
  269. #define YYERRCODE    256
  270.  
  271. #ifndef YYPURE
  272. #define YYLEX        yylex()
  273. #endif
  274.  
  275. #ifdef YYPURE
  276. #ifdef YYLSP_NEEDED
  277. #define YYLEX        yylex(&yylval, &yylloc)
  278. #else
  279. #define YYLEX        yylex(&yylval)
  280. #endif
  281. #endif
  282.  
  283. /* If nonreentrant, generate the variables here */
  284.  
  285. #ifndef YYPURE
  286.  
  287. int    yychar;            /*  the lookahead symbol        */
  288. YYSTYPE    yylval;            /*  the semantic value of the        */
  289.                 /*  lookahead symbol            */
  290.  
  291. #ifdef YYLSP_NEEDED
  292. YYLTYPE yylloc;            /*  location data for the lookahead    */
  293.                 /*  symbol                */
  294. #endif
  295.  
  296. int yynerrs;            /*  number of parse errors so far       */
  297. #endif  /* not YYPURE */
  298.  
  299. #if YYDEBUG != 0
  300. int yydebug;            /*  nonzero means print parse trace    */
  301. /* Since this is uninitialized, it does not stop multiple parsers
  302.    from coexisting.  */
  303. #endif
  304.  
  305. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  306.  
  307. #ifndef    YYINITDEPTH
  308. #define YYINITDEPTH 200
  309. #endif
  310.  
  311. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  312.     (effective only if the built-in stack extension method is used).  */
  313.  
  314. #if YYMAXDEPTH == 0
  315. #undef YYMAXDEPTH
  316. #endif
  317.  
  318. #ifndef YYMAXDEPTH
  319. #define YYMAXDEPTH 10000
  320. #endif
  321.  
  322. #ifndef __cplusplus
  323.  
  324. /* This is the most reliable way to avoid incompatibilities
  325.    in available built-in functions on various systems.  */
  326. static void
  327. __yy_bcopy (from, to, count)
  328.      char *from;
  329.      char *to;
  330.      int count;
  331. {
  332.   register char *f = from;
  333.   register char *t = to;
  334.   register int i = count;
  335.  
  336.   while (i-- > 0)
  337.     *t++ = *f++;
  338. }
  339.  
  340. #else /* __cplusplus */
  341.  
  342. /* This is the most reliable way to avoid incompatibilities
  343.    in available built-in functions on various systems.  */
  344. static void
  345. __yy_bcopy (char *from, char *to, int count)
  346. {
  347.   register char *f = from;
  348.   register char *t = to;
  349.   register int i = count;
  350.  
  351.   while (i-- > 0)
  352.     *t++ = *f++;
  353. }
  354.  
  355. #endif
  356.  
  357. #line 160 "bison.simple"
  358. int
  359. yyparse()
  360. {
  361.   register int yystate;
  362.   register int yyn;
  363.   register short *yyssp;
  364.   register YYSTYPE *yyvsp;
  365.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  366.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  367.  
  368.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  369.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  370.  
  371.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  372.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  373.  
  374. #ifdef YYLSP_NEEDED
  375.   YYLTYPE *yyls = yylsa;
  376.   YYLTYPE *yylsp;
  377.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  378.  
  379. #define YYPOPSTACK   (yyvsp--, yysp--, yylsp--)
  380. #else
  381. #define YYPOPSTACK   (yyvsp--, yysp--)
  382. #endif
  383.  
  384.   int yystacksize = YYINITDEPTH;
  385.  
  386. #ifdef YYPURE
  387.   int yychar;
  388.   YYSTYPE yylval;
  389.   int yynerrs;
  390. #ifdef YYLSP_NEEDED
  391.   YYLTYPE yylloc;
  392. #endif
  393. #endif
  394.  
  395.   YYSTYPE yyval;        /*  the variable used to return        */
  396.                 /*  semantic values from the action    */
  397.                 /*  routines                */
  398.  
  399.   int yylen;
  400.  
  401. #if YYDEBUG != 0
  402.   if (yydebug)
  403.     fprintf(stderr, "Starting parse\n");
  404. #endif
  405.  
  406.   yystate = 0;
  407.   yyerrstatus = 0;
  408.   yynerrs = 0;
  409.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  410.  
  411.   /* Initialize stack pointers.
  412.      Waste one element of value and location stack
  413.      so that they stay on the same level as the state stack.  */
  414.  
  415.   yyssp = yyss - 1;
  416.   yyvsp = yyvs;
  417. #ifdef YYLSP_NEEDED
  418.   yylsp = yyls;
  419. #endif
  420.  
  421. /* Push a new state, which is found in  yystate  .  */
  422. /* In all cases, when you get here, the value and location stacks
  423.    have just been pushed. so pushing a state here evens the stacks.  */
  424. yynewstate:
  425.  
  426.   *++yyssp = yystate;
  427.  
  428.   if (yyssp >= yyss + yystacksize - 1)
  429.     {
  430.       /* Give user a chance to reallocate the stack */
  431.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  432.       YYSTYPE *yyvs1 = yyvs;
  433.       short *yyss1 = yyss;
  434. #ifdef YYLSP_NEEDED
  435.       YYLTYPE *yyls1 = yyls;
  436. #endif
  437.  
  438.       /* Get the current used size of the three stacks, in elements.  */
  439.       int size = yyssp - yyss + 1;
  440.  
  441. #ifdef yyoverflow
  442.       /* Each stack pointer address is followed by the size of
  443.      the data in use in that stack, in bytes.  */
  444.       yyoverflow("parser stack overflow",
  445.          &yyss1, size * sizeof (*yyssp),
  446.          &yyvs1, size * sizeof (*yyvsp),
  447. #ifdef YYLSP_NEEDED
  448.          &yyls1, size * sizeof (*yylsp),
  449. #endif
  450.          &yystacksize);
  451.  
  452.       yyss = yyss1; yyvs = yyvs1;
  453. #ifdef YYLSP_NEEDED
  454.       yyls = yyls1;
  455. #endif
  456. #else /* no yyoverflow */
  457.       /* Extend the stack our own way.  */
  458.       if (yystacksize >= YYMAXDEPTH)
  459.     {
  460.       yyerror("parser stack overflow");
  461.       return 2;
  462.     }
  463.       yystacksize *= 2;
  464.       if (yystacksize > YYMAXDEPTH)
  465.     yystacksize = YYMAXDEPTH;
  466.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  467.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  468.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  469.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  470. #ifdef YYLSP_NEEDED
  471.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  472.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  473. #endif
  474. #endif /* no yyoverflow */
  475.  
  476.       yyssp = yyss + size - 1;
  477.       yyvsp = yyvs + size - 1;
  478. #ifdef YYLSP_NEEDED
  479.       yylsp = yyls + size - 1;
  480. #endif
  481.  
  482. #if YYDEBUG != 0
  483.       if (yydebug)
  484.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  485. #endif
  486.  
  487.       if (yyssp >= yyss + yystacksize - 1)
  488.     YYABORT;
  489.     }
  490.  
  491. #if YYDEBUG != 0
  492.   if (yydebug)
  493.     fprintf(stderr, "Entering state %d\n", yystate);
  494. #endif
  495.  
  496.  yybackup:
  497.  
  498. /* Do appropriate processing given the current state.  */
  499. /* Read a lookahead token if we need one and don't already have one.  */
  500. /* yyresume: */
  501.  
  502.   /* First try to decide what to do without reference to lookahead token.  */
  503.  
  504.   yyn = yypact[yystate];
  505.   if (yyn == YYFLAG)
  506.     goto yydefault;
  507.  
  508.   /* Not known => get a lookahead token if don't already have one.  */
  509.  
  510.   /* yychar is either YYEMPTY or YYEOF
  511.      or a valid token in external form.  */
  512.  
  513.   if (yychar == YYEMPTY)
  514.     {
  515. #if YYDEBUG != 0
  516.       if (yydebug)
  517.     fprintf(stderr, "Reading a token: ");
  518. #endif
  519.       yychar = YYLEX;
  520.     }
  521.  
  522.   /* Convert token to internal form (in yychar1) for indexing tables with */
  523.  
  524.   if (yychar <= 0)        /* This means end of input. */
  525.     {
  526.       yychar1 = 0;
  527.       yychar = YYEOF;        /* Don't call YYLEX any more */
  528.  
  529. #if YYDEBUG != 0
  530.       if (yydebug)
  531.     fprintf(stderr, "Now at end of input.\n");
  532. #endif
  533.     }
  534.   else
  535.     {
  536.       yychar1 = YYTRANSLATE(yychar);
  537.  
  538. #if YYDEBUG != 0
  539.       if (yydebug)
  540.     fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]);
  541. #endif
  542.     }
  543.  
  544.   yyn += yychar1;
  545.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  546.     goto yydefault;
  547.  
  548.   yyn = yytable[yyn];
  549.  
  550.   /* yyn is what to do for this token type in this state.
  551.      Negative => reduce, -yyn is rule number.
  552.      Positive => shift, yyn is new state.
  553.        New state is final state => don't bother to shift,
  554.        just return success.
  555.      0, or most negative number => error.  */
  556.  
  557.   if (yyn < 0)
  558.     {
  559.       if (yyn == YYFLAG)
  560.     goto yyerrlab;
  561.       yyn = -yyn;
  562.       goto yyreduce;
  563.     }
  564.   else if (yyn == 0)
  565.     goto yyerrlab;
  566.  
  567.   if (yyn == YYFINAL)
  568.     YYACCEPT;
  569.  
  570.   /* Shift the lookahead token.  */
  571.  
  572. #if YYDEBUG != 0
  573.   if (yydebug)
  574.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  575. #endif
  576.  
  577.   /* Discard the token being shifted unless it is eof.  */
  578.   if (yychar != YYEOF)
  579.     yychar = YYEMPTY;
  580.  
  581.   *++yyvsp = yylval;
  582. #ifdef YYLSP_NEEDED
  583.   *++yylsp = yylloc;
  584. #endif
  585.  
  586.   /* count tokens shifted since error; after three, turn off error status.  */
  587.   if (yyerrstatus) yyerrstatus--;
  588.  
  589.   yystate = yyn;
  590.   goto yynewstate;
  591.  
  592. /* Do the default action for the current state.  */
  593. yydefault:
  594.  
  595.   yyn = yydefact[yystate];
  596.   if (yyn == 0)
  597.     goto yyerrlab;
  598.  
  599. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  600. yyreduce:
  601.   yylen = yyr2[yyn];
  602.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  603.  
  604. #if YYDEBUG != 0
  605.   if (yydebug)
  606.     {
  607.       int i;
  608.  
  609.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  610.            yyn, yyrline[yyn]);
  611.  
  612.       /* Print the symboles being reduced, and their result.  */
  613.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  614.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  615.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  616.     }
  617. #endif
  618.  
  619.  
  620.   switch (yyn) {
  621.  
  622. case 8:
  623. #line 81 "parser.bison"
  624. { from_x = '9' - yyvsp[0].string[0]; 
  625.          from_y = 'i' - yyvsp[0].string[1];
  626.          strcpy(currentMoveString,yyvsp[0].string); ;
  627.     break;}
  628. case 9:
  629. #line 84 "parser.bison"
  630. { to_x = '9' - yyvsp[0].string[0]; 
  631.          to_y = 'i' - yyvsp[0].string[1];
  632.          strcat(currentMoveString,yyvsp[0].string); ;
  633.     break;}
  634. case 10:
  635. #line 87 "parser.bison"
  636. { move_type = NormalMove; ;
  637.     break;}
  638. case 11:
  639. #line 89 "parser.bison"
  640.       SendToProgram(currentMoveString, toFirstProgFP);
  641.       strcpy(moveList[currentMove], currentMoveString);
  642.       MakeMove(&move_type, from_x, from_y, to_x, to_y);
  643.     ;
  644.     break;}
  645. case 12:
  646. #line 95 "parser.bison"
  647. { piece = yyvsp[0].string[0]; strcpy(currentMoveString,yyvsp[0].string); ;
  648.     break;}
  649. case 13:
  650. #line 96 "parser.bison"
  651. { strcat(currentMoveString,"*"); ;
  652.     break;}
  653. case 14:
  654. #line 97 "parser.bison"
  655. { to_x = '9' - yyvsp[0].string[0]; 
  656.          to_y = 'i' - yyvsp[0].string[1];
  657.          strcat(currentMoveString,yyvsp[0].string); ;
  658.     break;}
  659. case 15:
  660. #line 100 "parser.bison"
  661.       move_type = (BLACK_ON_MOVE ? BlackDrop : WhiteDrop );
  662.       switch ( piece ) {
  663.         case 'P': from_x = 81; break;
  664.         case 'L': from_x = 82; break;
  665.         case 'N': from_x = 83; break;
  666.         case 'S': from_x = 84; break;
  667.         case 'G': from_x = 85; break;
  668.         case 'B': from_x = 86; break;
  669.         case 'R': from_x = 87; break;
  670.         case 'K': from_x = 88; break;
  671.         default:  from_x = -1;
  672.       };
  673.       from_y = from_x;
  674.       SendToProgram(currentMoveString, toFirstProgFP);
  675.       strcpy(moveList[currentMove], currentMoveString);
  676.       MakeMove(&move_type, from_x, from_y, to_x, to_y);
  677.     ;
  678.     break;}
  679. case 17:
  680. #line 123 "parser.bison"
  681. { move_type = (BLACK_ON_MOVE ? BlackPromotion : WhitePromotion ); 
  682.       strcat(currentMoveString,"+"); ;
  683.     break;}
  684. }
  685.    /* the action file gets copied in in place of this dollarsign */
  686. #line 423 "bison.simple"
  687.  
  688.   yyvsp -= yylen;
  689.   yyssp -= yylen;
  690. #ifdef YYLSP_NEEDED
  691.   yylsp -= yylen;
  692. #endif
  693.  
  694. #if YYDEBUG != 0
  695.   if (yydebug)
  696.     {
  697.       short *ssp1 = yyss - 1;
  698.       fprintf (stderr, "state stack now");
  699.       while (ssp1 != yyssp)
  700.     fprintf (stderr, " %d", *++ssp1);
  701.       fprintf (stderr, "\n");
  702.     }
  703. #endif
  704.  
  705.   *++yyvsp = yyval;
  706.  
  707. #ifdef YYLSP_NEEDED
  708.   yylsp++;
  709.   if (yylen == 0)
  710.     {
  711.       yylsp->first_line = yylloc.first_line;
  712.       yylsp->first_column = yylloc.first_column;
  713.       yylsp->last_line = (yylsp-1)->last_line;
  714.       yylsp->last_column = (yylsp-1)->last_column;
  715.       yylsp->text = 0;
  716.     }
  717.   else
  718.     {
  719.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  720.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  721.     }
  722. #endif
  723.  
  724.   /* Now "shift" the result of the reduction.
  725.      Determine what state that goes to,
  726.      based on the state we popped back to
  727.      and the rule number reduced by.  */
  728.  
  729.   yyn = yyr1[yyn];
  730.  
  731.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  732.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  733.     yystate = yytable[yystate];
  734.   else
  735.     yystate = yydefgoto[yyn - YYNTBASE];
  736.  
  737.   goto yynewstate;
  738.  
  739. yyerrlab:   /* here on detecting error */
  740.  
  741.   if (! yyerrstatus)
  742.     /* If not already recovering from an error, report this error.  */
  743.     {
  744.       ++yynerrs;
  745.  
  746. #ifdef YYERROR_VERBOSE
  747.       yyn = yypact[yystate];
  748.  
  749.       if (yyn > YYFLAG && yyn < YYLAST)
  750.     {
  751.       int size = 0;
  752.       char *msg;
  753.       int x, count;
  754.  
  755.       count = 0;
  756.       for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  757.         if (yycheck[x + yyn] == x)
  758.           size += strlen(yytname[x]) + 15, count++;
  759.       msg = (char *) xmalloc(size + 15);
  760.       strcpy(msg, "parse error");
  761.  
  762.       if (count < 5)
  763.         {
  764.           count = 0;
  765.           for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  766.         if (yycheck[x + yyn] == x)
  767.           {
  768.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  769.             strcat(msg, yytname[x]);
  770.             strcat(msg, "'");
  771.             count++;
  772.           }
  773.         }
  774.       yyerror(msg);
  775.       free(msg);
  776.     }
  777.       else
  778. #endif /* YYERROR_VERBOSE */
  779.     yyerror("parse error");
  780.     }
  781.  
  782. yyerrlab1:   /* here on error raised explicitly by an action */
  783.  
  784.   if (yyerrstatus == 3)
  785.     {
  786.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  787.  
  788.       /* return failure if at end of input */
  789.       if (yychar == YYEOF)
  790.     YYABORT;
  791.  
  792. #if YYDEBUG != 0
  793.       if (yydebug)
  794.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  795. #endif
  796.  
  797.       yychar = YYEMPTY;
  798.     }
  799.  
  800.   /* Else will try to reuse lookahead token
  801.      after shifting the error token.  */
  802.  
  803.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  804.  
  805.   goto yyerrhandle;
  806.  
  807. yyerrdefault:  /* current state does not do anything special for the error token. */
  808.  
  809. #if 0
  810.   /* This is wrong; only states that explicitly want error tokens
  811.      should shift them.  */
  812.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  813.   if (yyn) goto yydefault;
  814. #endif
  815.  
  816. yyerrpop:   /* pop the current state because it cannot handle the error token */
  817.  
  818.   if (yyssp == yyss) YYABORT;
  819.   yyvsp--;
  820.   yystate = *--yyssp;
  821. #ifdef YYLSP_NEEDED
  822.   yylsp--;
  823. #endif
  824.  
  825. #if YYDEBUG != 0
  826.   if (yydebug)
  827.     {
  828.       short *ssp1 = yyss - 1;
  829.       fprintf (stderr, "Error: state stack now");
  830.       while (ssp1 != yyssp)
  831.     fprintf (stderr, " %d", *++ssp1);
  832.       fprintf (stderr, "\n");
  833.     }
  834. #endif
  835.  
  836. yyerrhandle:
  837.  
  838.   yyn = yypact[yystate];
  839.   if (yyn == YYFLAG)
  840.     goto yyerrdefault;
  841.  
  842.   yyn += YYTERROR;
  843.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  844.     goto yyerrdefault;
  845.  
  846.   yyn = yytable[yyn];
  847.   if (yyn < 0)
  848.     {
  849.       if (yyn == YYFLAG)
  850.     goto yyerrpop;
  851.       yyn = -yyn;
  852.       goto yyreduce;
  853.     }
  854.   else if (yyn == 0)
  855.     goto yyerrpop;
  856.  
  857.   if (yyn == YYFINAL)
  858.     YYACCEPT;
  859.  
  860. #if YYDEBUG != 0
  861.   if (yydebug)
  862.     fprintf(stderr, "Shifting error token, ");
  863. #endif
  864.  
  865.   *++yyvsp = yylval;
  866. #ifdef YYLSP_NEEDED
  867.   *++yylsp = yylloc;
  868. #endif
  869.  
  870.   yystate = yyn;
  871.   goto yynewstate;
  872. }
  873. #line 127 "parser.bison"
  874.  
  875.  
  876.  
  877.  
  878. #include "scanner.c"
  879.  
  880.  
  881. static void yyerror (errmsg)
  882. char *errmsg;
  883. { fprintf(stderr,"parse error in game file line %d column %d : %s\n",lines,cols,errmsg); 
  884.   exit(-1); 
  885. }
  886.        
  887.  
  888. void parseGameFile ()
  889.   yyin = gameFileFP;
  890.   outfile = stderr;
  891.   yyparse();
  892. }
  893.  
  894.